<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php $_helper = $this->helper('catalog/output');?>

<div class='all-reviews-container'>
	<div class="all-reviews-title">
		<p><?php echo $this->__('Reviews Of All ') . $this->getCategory()->getName() ?></p>
		<div class='pager-box'><?php echo $this->getToolbarHtml() ?></div>
	</div>
<?php if( $this->getCollection() && $this->count()): ?>
	<ul class='review-contanier'>
	<?php $i = 0;?>
	<?php foreach($this->getCollection() as $_item){
	$i++;
	$_product = Mage::getModel('catalog/product')->load($_item->getId());
	?>
		<li <?php if($i == count($this->getCollection())){echo 'class="last"';}?>>
			<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
				<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
			</a>
			<div class='review-content-right'>
				<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
				<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>

				<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>

				<?php if($_review = Mage::getModel('review/review')->load($_item->getReviewId())){?>
				<strong><?php echo $this->htmlEscape($_review->getTitle()) ?></strong><br/>
				<?php echo $this->__('Reviewed by <strong>%s</strong>', $this->htmlEscape($_review->getNickname())) ?>
				<span class="r_time"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></span>

				<div class='review_detail'>
					<div class="replay-box">
						<div class="replay-bottom">
							<div class="replay-content">
								<p class="r_content"><?php $detail = nl2br($this->htmlEscape($_review->getDetail())); if(strlen($detail)<150){echo $detail;}else{echo substr($detail,0 ,150),'<span id="reviewdot-',$i,'">...&nbsp;&nbsp;&nbsp;</span><span id="review-more-',$i,'" style="display:none">',substr($detail,150),'</span><a href="javascript:void(0);" onclick="reviewMore(',$i,')" id="review-txt-more-',$i,'">' .$this->__('Read more') .'</a>';} ?>
									<a href="javascript:void(0);" style="display:none;" onclick="reviewLess('<?php echo $i?>');" id="review-txt-less-<?php echo $i;?>">&nbsp;&nbsp;&nbsp;<?php echo $this->__('Less')?></a>
								</p>
							</div>
						</div>
					</div>
							  
				    <?php if($_review->getReply()):?>
					<div style="width:100%;height:20px;"></div>
					<?php echo $this->__('Replied by ')?><strong><?php echo $this->__('HairExtensions Support')?></strong><span class="r_time"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getReplyAt()), 'long') ?></span>
					<div class="replay-box">
						<div class="replay-bottom">
							<div class="replay-content r_content">
								<?php echo $_review->getReply() ?> 
							</div>
						</div>
					</div>
				    <?php endif;?>
					
				</div>
				<?php } ?>

			    <?php if ($_images = $this->getImages($_review)){?>
				<div style='padding-top:10px;padding-left:35px;'>
				<?php foreach($_images as $_image){?>
					<a style='display:block;float:left;margin-left:15px;width:90px;height:90px;' class='MagicZoomPlus' rel="disable-zoom:true;background-opacity:70;background-color:#FFFFFF;group:group_<?php echo $_review->getId()?>;" href="<?php echo $this->helper('review/image')->initImage($_image, 'image_no_water');?>">
						<img style="border:1px solid #dddddd;" src='<?php echo $this->helper('review/image')->initImage($_image, 'thumbnail')->resize(89, 89);?>' />
					</a>
				<?php }?>
				</div>
				<?php }?>

			</div>
			<div class='clear'></div>
		</li>
	<?php }?>
	</ul>  
<?php else: ?>
    <p><?php echo $this->__('No reviews in this category.') ?></p>
<?php endif; ?>
	<div class="all-reviews-bottom">
		<p class="back-link">
			<a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
				<img src='<?php echo $this->getSkinUrl('images/reviews_go_back.jpg')?>' />
				<?php echo $this->__('Go Back')?>:<span><?php echo $this->getCategory()->getName();?></span>
			</a>
		</p>
		<div class='pager-box'>
		 <?php echo $this->getToolbarHtml() ?>
		</div>
	</div>
</div>

<script type="text/javascript">
function reviewMore(i){
    document.getElementById('review-more-'+i).style.display = '';
    document.getElementById('reviewdot-'+i).style.display = 'none';
    document.getElementById('review-txt-more-'+i).style.display='none';
    document.getElementById('review-txt-less-'+i).style.display='';
}
function reviewLess(i){
    document.getElementById('review-more-'+i).style.display = 'none';
    document.getElementById('reviewdot-'+i).style.display = '';
    document.getElementById('review-txt-more-'+i).style.display='';
    document.getElementById('review-txt-less-'+i).style.display='none';
}
</script>
